package com.example.accessibilitydemo;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;

import com.kk.permission.PermissionWrapper;
import com.kk.permission.handler.ConfigHandler;
import com.kk.permission.utils.BaseUtil;
import com.kk.permission.utils.Permission;

import java.util.ArrayList;


public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        initActivityLifeCycle();
        PermissionWrapper.getInst().init(this);

    }


    private void initActivityLifeCycle() {
        try {
            registerActivityLifecycleCallbacks(new ApplicationCallback());
        } catch (Exception e) {
        } catch (Error e) {
        }
    }

    class ApplicationCallback implements Application.ActivityLifecycleCallbacks {
        @Override
        public void onActivityCreated(final Activity activity, Bundle savedInstanceState) {
            if (activity != null) {
                ConfigHandler.getInstance().setAppName(getString(R.string.app_name))
                        .setInstallShortCutDisplayName("炫闪来电秀快捷方式")
                        .setIconResId(R.drawable.ic_launcher_background)
                        .setServiceLabel(getString(R.string.app_name))
                        .setQuitDialogContent("权限未全部开启，可能导致无法正常展示来电秀功能")
                        .setPermissionList(Permission.TOAST,
                                Permission.AUTO_BOOT,
                                Permission.CALL_RINGTONE,
                                Permission.DIAL_NOTI,
                                Permission.LOCK_SCREEN_SHOW,
                                Permission.BACKGROUND_SHOW,
                                Permission.BACKGROUND_PROTECT,
                                Permission.SHORTCUT,
                                Permission.BACKGROUND_FROZEN,
                                Permission.SYSTEM_DIALING);

                BaseUtil.init(new BaseUtil.IAdapter() {
                    @Override
                    public Context getAppContext() {
                        return getApplicationContext();
                    }

                    @Override
                    public String getChannelCode() {
                        return null;
                    }

                    @Override
                    public String getLoginSecret() {
                        return null;
                    }

                    @Override
                    public String getSimPhoneNumber() {
                        return null;
                    }

                    @Override
                    public ArrayList<String> getWS2ProxyAddress() {
                        return null;
                    }

                    @Override
                    public boolean isDebugMode() {
                        return false;
                    }

                    @Override
                    public boolean isDebugServer() {
                        return false;
                    }

                    @Override
                    public boolean isStrictDebugMode() {
                        return false;
                    }
                });
            }
        }

        @Override
        public void onActivityStarted(Activity activity) {
        }

        @Override
        public void onActivityResumed(Activity activity) {
        }

        @Override
        public void onActivityPaused(Activity activity) {
        }

        @Override
        public void onActivityStopped(Activity activity) {
        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
        }

        @Override
        public void onActivityDestroyed(Activity activity) {
        }
    }
}
